Skip to content

Add bounds check before memcpy/strncpy in dump_pool_info handler - #9110

Open
Pyolar wants to merge 1 commit into
FirebirdSQL:masterfrom
Pyolar:fix/dpb-clumplet-bounds-check
Open

Add bounds check before memcpy/strncpy in dump_pool_info handler#9110
Pyolar wants to merge 1 commit into
FirebirdSQL:masterfrom
Pyolar:fix/dpb-clumplet-bounds-check

Conversation

@Pyolar

@Pyolar Pyolar commented Jul 31, 2026

Copy link
Copy Markdown

Service::query() and Service::query2() both handle isc_info_svc_dump_pool_info
by reading a 2-byte length from the SPB, advancing items past it, then
calling memcpy / strncpy to copy data into fname.

length2 is only checked against sizeof(fname) to prevent destination
overflow. There is no check that items + length2 stays within the SPB
buffer (end_items / end_items2). A crafted SPB with a dump_pool_info
clumplet whose declared length exceeds the remaining buffer causes
out-of-bounds read from the items pointer.

Fix: clamp length2 to 0 when items >= end or items + length2 > end.

@hvlad

hvlad commented Jul 31, 2026

Copy link
Copy Markdown
Member

Really correct handling should return corresponding error, not silently ignore the value passed.

But, this internal and not documented SPB item is no-op for a long time, and better will be to remove it or to complete implementation, imho.

This is not demand for you to go in this way, just call for opinions - should we fix it properly or remove it finally.

@aafemt

aafemt commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Taking into account that items is not advanced after copying, I would say that this code never worked.

+1 for complete removal.

This SPB item has never worked - items pointer is not advanced after
the copy, causing an infinite loop.  The handler also reads a
network-supplied length without checking it against the SPB buffer
boundary.

Remove both occurrences in Service::query() and Service::query2().
Per maintainers' feedback, dead code is better deleted than fixed.
@Pyolar
Pyolar force-pushed the fix/dpb-clumplet-bounds-check branch from 74a5252 to 39b17e8 Compare July 31, 2026 07:31
@Pyolar

Pyolar commented Jul 31, 2026

Copy link
Copy Markdown
Author

Removed both dead isc_info_svc_dump_pool_info case branches in Service::query() and Service::query2(). If the preference is to fix it properly instead of deleting, I will update this PR accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants